<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="签单日期" label-width="100">
        <el-date-picker
          v-model="dateRange"
          value-format="YYYY-MM-DD HH:mm:ss"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="[
            new Date(2000, 1, 1, 0, 0, 0),
            new Date(2000, 1, 1, 23, 59, 59),
          ]"
        ></el-date-picker>
      </el-form-item>

      <el-form-item label="客户昵称" prop="customerNickname" label-width="100">
        <el-input
          v-model="queryParams.customerNickname"
          placeholder="客户昵称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>

      <el-form-item label="客户手机号" prop="phonenumber" label-width="100">
        <el-input
          v-model="queryParams.phonenumber"
          placeholder="客户昵称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>

      <el-form-item label="门店名称" prop="shopName" label-width="100">
        <el-input
          v-model="queryParams.shopName"
          placeholder="门店名称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>

      <el-form-item label="补发师名字" prop="teacherName" label-width="100">
        <el-input
          v-model="queryParams.teacherName"
          placeholder="补发师名字"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品分类" prop="teacherName" label-width="100">
        <el-select clearable @change="handleQuery" v-model="queryParams.productCategory" placeholder="请选择">
          <el-option label="头发" value="头发"></el-option>
          <el-option label="非头发" value="非头发"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="小程序用户签单" prop="isXcxUser" label-width="120">
        <el-select clearable @change="handleQuery" v-model="queryParams.isXcxUser" placeholder="请选择">
          <el-option label="是" value="1"></el-option>
        </el-select>
      </el-form-item>




      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['business:hairTriggerEvent:export']"
        >导出</el-button
        >
      </el-form-item>
    </el-form>

<!--    <el-row :gutter="10" class="mb8">-->
<!--      <right-toolbar-->
<!--        v-model:showSearch="showSearch"-->
<!--        @queryTable="getList"-->
<!--      ></right-toolbar>-->
<!--    </el-row>-->

    <el-table
      v-loading="loading"
      :data="hairTriggerEventList"
    >
      <el-table-column label="签单日期" align="center" prop="signingDate" />
      <el-table-column label="客户昵称" align="center" prop="customerNickname" />
      <el-table-column label="客户ID" align="center" prop="customerId" />
      <el-table-column label="客户手机号" align="center" prop="phonenumber" />
      <el-table-column label="小程序用户手机号" align="center" prop="xcxPhoneNumber" />
      <el-table-column label="门店" align="center" prop="shopName" />
      <el-table-column label="补发师" align="center" prop="teacherName" />
      <el-table-column label="签单项目" align="center" prop="signProject" />
      <el-table-column label="签单金额" align="center" prop="signPrice" />
      <el-table-column label="支付方式" align="center" prop="payment" />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script setup name="HairTriggerEvent">
import {
  getBokaAccountStatement
} from "@/api/business/operation";
const { proxy } = getCurrentInstance();

const hairTriggerEventList = ref([]);
const open = ref(false);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const dateRange = ref([proxy.parseTime(new Date(), "{y}-{m}-{d}") + ' 00:00:00' ,proxy.parseTime(new Date(), "{y}-{m}-{d}") + ' 23:59:59']);
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 15,
    nickName: undefined,
    queryUser: "1",
    salesDirector: undefined,
    eventValue: undefined,
  },
});

const { queryParams, form, rules } = toRefs(data);

/** 查询用户触发事件记录列表 */
function getList() {
  loading.value = true;
  getBokaAccountStatement(proxy.addDateRange(queryParams.value, dateRange.value)).then((response) => {
    hairTriggerEventList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}


/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  dateRange.value = [];
  queryParams.value = {
    pageNum: 1,
    pageSize: 15,
    userId: null,
    type: null,
    startDate: null,
    endDate: null,
    nickName: null,
    salesDirector: null,
    eventValue: null,
  };
  handleQuery();
}





/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "business/operation/exportbokaAccountStatement",
    {
      ...queryParams.value,
    },
    `accountStatement_${new Date().getTime()}.xlsx`
  );
}

getList();
</script>
